import request from '@/utils/request'

export const templateBackupApi = {
  // 获取备份列表
  getBackupList(params: {
    page: number
    size: number
    keyword?: string
  }) {
    return request({
      url: '/admin/template-backup/list',
      method: 'get',
      params
    })
  },

  // 创建备份
  createBackup(data: {
    name: string
    description?: string
    scope: string
    format: string
  }) {
    return request({
      url: '/admin/template-backup/create',
      method: 'post',
      data
    })
  },

  // 下载备份
  downloadBackup(id: number) {
    return request({
      url: `/admin/template-backup/download/${id}`,
      method: 'get',
      responseType: 'blob'
    })
  },

  // 删除备份
  deleteBackup(id: number) {
    return request({
      url: `/admin/template-backup/${id}`,
      method: 'delete'
    })
  },

  // 获取备份详情
  getBackupDetail(id: number) {
    return request({
      url: `/admin/template-backup/${id}`,
      method: 'get'
    })
  },

  // 批量删除备份
  batchDeleteBackups(ids: number[]) {
    return request({
      url: '/admin/template-backup/batch-delete',
      method: 'delete',
      data: { ids }
    })
  }
}
